using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using DIS_DAL_WS.Models;
namespace DIS_DAL_WS
{
	#region Using
	using DIS_DAL_WS.Models;
	using DIS_DAL_WS.Repositories;
	using DIS_DAL_WS.Helpers;
	using DIS_DAL_WS.DTO;
	#endregion
	public class DIS_DAL_Service: IDIS_DAL_Service
	{
		/////////////////// CATEGORY ///////////////////
		public List<CategoryDTO> Category_SelectAll()
		{
			var lstDto = new List<CategoryDTO>();
			var rpt = new CategoryRepository();
			var lstEntity = rpt.SelectAll();
			foreach (var item in lstEntity)
			{
				lstDto.Add(CategoryDTO.Translate(item));
			}
			return lstDto;
		}
		public CategoryDTO Category_SelectByID(int id)
		{
			var rpt = new CategoryRepository();
			return CategoryDTO.Translate(rpt.SelectByID(id));
		}
		public bool Category_Insert(CategoryDTO obj)
		{
			var rpt = new CategoryRepository();
			var entity = CategoryDTO.Reverse(obj);
			return rpt.Insert(entity);
		}
		public bool Category_Delete(int id)
		{
			var rpt = new CategoryRepository();
			return rpt.Delete(id);
		}
		public bool Category_Update(CategoryDTO obj)
		{
			var rpt = new CategoryRepository();
			var entity = rpt.SelectByID(obj.ID);
			obj.UpdateEntity(ref entity);
			return rpt.Save();
		}
		public List<CategoryDTO> Category_RetrieveByID(int id)
		{
			var rpt = new CategoryRepository();
			var lstDto = new List<CategoryDTO>();
			var lstEntity = rpt.RetrieveByID(id);
			foreach (var item in lstEntity)
			{
				lstDto.Add(CategoryDTO.Translate(item));
			}
			return lstDto;
		}
		/////////////////// DAILYREPORT ///////////////////
		public List<DailyReportDTO> DailyReport_SelectAll()
		{
			var lstDto = new List<DailyReportDTO>();
			var rpt = new DailyReportRepository();
			var lstEntity = rpt.SelectAll();
			foreach (var item in lstEntity)
			{
				lstDto.Add(DailyReportDTO.Translate(item));
			}
			return lstDto;
		}
		public DailyReportDTO DailyReport_SelectByID(int id)
		{
			var rpt = new DailyReportRepository();
			return DailyReportDTO.Translate(rpt.SelectByID(id));
		}
		public bool DailyReport_Insert(DailyReportDTO obj)
		{
			var rpt = new DailyReportRepository();
			var entity = DailyReportDTO.Reverse(obj);
			return rpt.Insert(entity);
		}
		public bool DailyReport_Delete(int id)
		{
			var rpt = new DailyReportRepository();
			return rpt.Delete(id);
		}
		public bool DailyReport_Update(DailyReportDTO obj)
		{
			var rpt = new DailyReportRepository();
			var entity = rpt.SelectByID(obj.ID);
			obj.UpdateEntity(ref entity);
			return rpt.Save();
		}
		public List<DailyReportDTO> DailyReport_RetrieveByID(int id)
		{
			var rpt = new DailyReportRepository();
			var lstDto = new List<DailyReportDTO>();
			var lstEntity = rpt.RetrieveByID(id);
			foreach (var item in lstEntity)
			{
				lstDto.Add(DailyReportDTO.Translate(item));
			}
			return lstDto;
		}
		public List<DailyReportDTO> DailyReport_SelectByIDRestaurant(int idrestaurant)
		{
			var rpt = new DailyReportRepository();
			var lstDto = new List<DailyReportDTO>();
			var lstEntity = rpt.SelectByIDRestaurant(idrestaurant);
			foreach (var item in lstEntity)
			{
				lstDto.Add(DailyReportDTO.Translate(item));
			}
			return lstDto;
		}
        public DailyReportDTO DailyReport_SelectByIDRestaurantAndReportDate(int idrestaurant, DateTime reportdate)
        {
            var rpt = new DailyReportRepository();
            return DailyReportDTO.Translate(rpt.SelectByIDRestaurantAndReportDate(idrestaurant, reportdate));
        }
		/////////////////// WEEKLYREPORT ///////////////////
		public List<WeeklyReportDTO> WeeklyReport_SelectAll()
		{
			var lstDto = new List<WeeklyReportDTO>();
			var rpt = new WeeklyReportRepository();
			var lstEntity = rpt.SelectAll();
			foreach (var item in lstEntity)
			{
				lstDto.Add(WeeklyReportDTO.Translate(item));
			}
			return lstDto;
		}
		public WeeklyReportDTO WeeklyReport_SelectByID(int id)
		{
			var rpt = new WeeklyReportRepository();
			return WeeklyReportDTO.Translate(rpt.SelectByID(id));
		}
		public bool WeeklyReport_Insert(WeeklyReportDTO obj)
		{
			var rpt = new WeeklyReportRepository();
			var entity = WeeklyReportDTO.Reverse(obj);
			return rpt.Insert(entity);
		}
		public bool WeeklyReport_Delete(int id)
		{
			var rpt = new WeeklyReportRepository();
			return rpt.Delete(id);
		}
		public bool WeeklyReport_Update(WeeklyReportDTO obj)
		{
			var rpt = new WeeklyReportRepository();
			var entity = rpt.SelectByID(obj.ID);
			obj.UpdateEntity(ref entity);
			return rpt.Save();
		}
		public List<WeeklyReportDTO> WeeklyReport_RetrieveByID(int id)
		{
			var rpt = new WeeklyReportRepository();
			var lstDto = new List<WeeklyReportDTO>();
			var lstEntity = rpt.RetrieveByID(id);
			foreach (var item in lstEntity)
			{
				lstDto.Add(WeeklyReportDTO.Translate(item));
			}
			return lstDto;
		}
		public List<WeeklyReportDTO> WeeklyReport_SelectByIDRestaurant(int idrestaurant)
		{
			var rpt = new WeeklyReportRepository();
			var lstDto = new List<WeeklyReportDTO>();
			var lstEntity = rpt.SelectByIDRestaurant(idrestaurant);
			foreach (var item in lstEntity)
			{
				lstDto.Add(WeeklyReportDTO.Translate(item));
			}
			return lstDto;
		}
        public WeeklyReportDTO WeeklyReport_SelectByIDRestaurantAndReportDate(int idrestaurant, DateTime startdate, DateTime enddate)
        {
            var rpt = new WeeklyReportRepository();
            return WeeklyReportDTO.Translate(rpt.SelectByIDRestaurantAndReportDate(idrestaurant, startdate, enddate));
        }
		/////////////////// ITEM ///////////////////
		public List<ItemDTO> Item_SelectAll()
		{
			var lstDto = new List<ItemDTO>();
			var rpt = new ItemRepository();
			var lstEntity = rpt.SelectAll();
			foreach (var item in lstEntity)
			{
				lstDto.Add(ItemDTO.Translate(item));
			}
			return lstDto;
		}
		public ItemDTO Item_SelectByID(int id)
		{
			var rpt = new ItemRepository();
			return ItemDTO.Translate(rpt.SelectByID(id));
		}
		public bool Item_Insert(ItemDTO obj)
		{
			var rpt = new ItemRepository();
			var entity = ItemDTO.Reverse(obj);
			return rpt.Insert(entity);
		}
		public bool Item_Delete(int id)
		{
			var rpt = new ItemRepository();
			return rpt.Delete(id);
		}
		public bool Item_Update(ItemDTO obj)
		{
			var rpt = new ItemRepository();
			var entity = rpt.SelectByID(obj.ID);
			obj.UpdateEntity(ref entity);
			return rpt.Save();
		}
		public List<ItemDTO> Item_RetrieveByID(int id)
		{
			var rpt = new ItemRepository();
			var lstDto = new List<ItemDTO>();
			var lstEntity = rpt.RetrieveByID(id);
			foreach (var item in lstEntity)
			{
				lstDto.Add(ItemDTO.Translate(item));
			}
			return lstDto;
		}
		public List<ItemDTO> Item_SelectByIDCategory(int idcategory)
		{
			var rpt = new ItemRepository();
			var lstDto = new List<ItemDTO>();
			var lstEntity = rpt.SelectByIDCategory(idcategory);
			foreach (var item in lstEntity)
			{
				lstDto.Add(ItemDTO.Translate(item));
			}
			return lstDto;
		}
		/////////////////// EMPLOYEE ///////////////////
		public List<EmployeeDTO> Employee_SelectAll()
		{
			var lstDto = new List<EmployeeDTO>();
			var rpt = new EmployeeRepository();
			var lstEntity = rpt.SelectAll();
			foreach (var item in lstEntity)
			{
				lstDto.Add(EmployeeDTO.Translate(item));
			}
			return lstDto;
		}
		public EmployeeDTO Employee_SelectByID(int id)
		{
			var rpt = new EmployeeRepository();
			return EmployeeDTO.Translate(rpt.SelectByID(id));
		}
		public bool Employee_Insert(EmployeeDTO obj)
		{
			var rpt = new EmployeeRepository();
			var entity = EmployeeDTO.Reverse(obj);
			return rpt.Insert(entity);
		}
		public bool Employee_Delete(int id)
		{
			var rpt = new EmployeeRepository();
			return rpt.Delete(id);
		}
		public bool Employee_Update(EmployeeDTO obj)
		{
			var rpt = new EmployeeRepository();
			var entity = rpt.SelectByID(obj.ID);
			obj.UpdateEntity(ref entity);
			return rpt.Save();
		}
		public List<EmployeeDTO> Employee_RetrieveByID(int id)
		{
			var rpt = new EmployeeRepository();
			var lstDto = new List<EmployeeDTO>();
			var lstEntity = rpt.RetrieveByID(id);
			foreach (var item in lstEntity)
			{
				lstDto.Add(EmployeeDTO.Translate(item));
			}
			return lstDto;
		}
		public List<EmployeeDTO> Employee_SelectByIDRole(int idrole)
		{
			var rpt = new EmployeeRepository();
			var lstDto = new List<EmployeeDTO>();
			var lstEntity = rpt.SelectByIDRole(idrole);
			foreach (var item in lstEntity)
			{
				lstDto.Add(EmployeeDTO.Translate(item));
			}
			return lstDto;
		}
		public List<EmployeeDTO> Employee_SelectByIDRestaurant(int idrestaurant)
		{
			var rpt = new EmployeeRepository();
			var lstDto = new List<EmployeeDTO>();
			var lstEntity = rpt.SelectByIDRestaurant(idrestaurant);
			foreach (var item in lstEntity)
			{
				lstDto.Add(EmployeeDTO.Translate(item));
			}
			return lstDto;
		}
        public EmployeeDTO Employee_SelectByUserName(string username)
        {
            var rpt = new EmployeeRepository();
            return EmployeeDTO.Translate(rpt.SelectByUserName(username));
        }
        public EmployeeDTO Employee_SelectByUserNameAndPassword(string username, string password)
        {
            var rpt = new EmployeeRepository();
            return EmployeeDTO.Translate(rpt.SelectByUserNameAndPassword(username, password));
        }
		/////////////////// NATIONALPROMOTION ///////////////////
		public List<NationalPromotionDTO> NationalPromotion_SelectAll()
		{
			var lstDto = new List<NationalPromotionDTO>();
			var rpt = new NationalPromotionRepository();
			var lstEntity = rpt.SelectAll();
			foreach (var item in lstEntity)
			{
				lstDto.Add(NationalPromotionDTO.Translate(item));
			}
			return lstDto;
		}
		public NationalPromotionDTO NationalPromotion_SelectByID(int id)
		{
			var rpt = new NationalPromotionRepository();
			return NationalPromotionDTO.Translate(rpt.SelectByID(id));
		}
		public bool NationalPromotion_Insert(NationalPromotionDTO obj)
		{
			var rpt = new NationalPromotionRepository();
			var entity = NationalPromotionDTO.Reverse(obj);
			return rpt.Insert(entity);
		}
		public bool NationalPromotion_Delete(int id)
		{
			var rpt = new NationalPromotionRepository();
			return rpt.Delete(id);
		}
		public bool NationalPromotion_Update(NationalPromotionDTO obj)
		{
			var rpt = new NationalPromotionRepository();
			var entity = rpt.SelectByID(obj.ID);
			obj.UpdateEntity(ref entity);
			return rpt.Save();
		}
		public List<NationalPromotionDTO> NationalPromotion_RetrieveByID(int id)
		{
			var rpt = new NationalPromotionRepository();
			var lstDto = new List<NationalPromotionDTO>();
			var lstEntity = rpt.RetrieveByID(id);
			foreach (var item in lstEntity)
			{
				lstDto.Add(NationalPromotionDTO.Translate(item));
			}
			return lstDto;
		}
        public NationalPromotionDTO NationalPromotion_SelectByIDItem(int iditem)
		{
			var rpt = new NationalPromotionRepository();
			return NationalPromotionDTO.Translate(rpt.SelectByIDItem(iditem));
		}
		/////////////////// LOCALPROMOTION ///////////////////
		public List<LocalPromotionDTO> LocalPromotion_SelectAll()
		{
			var lstDto = new List<LocalPromotionDTO>();
			var rpt = new LocalPromotionRepository();
			var lstEntity = rpt.SelectAll();
			foreach (var item in lstEntity)
			{
				lstDto.Add(LocalPromotionDTO.Translate(item));
			}
			return lstDto;
		}
		public LocalPromotionDTO LocalPromotion_SelectByID(int id)
		{
			var rpt = new LocalPromotionRepository();
			return LocalPromotionDTO.Translate(rpt.SelectByID(id));
		}
		public bool LocalPromotion_Insert(LocalPromotionDTO obj)
		{
			var rpt = new LocalPromotionRepository();
			var entity = LocalPromotionDTO.Reverse(obj);
			return rpt.Insert(entity);
		}
		public bool LocalPromotion_Delete(int id)
		{
			var rpt = new LocalPromotionRepository();
			return rpt.Delete(id);
		}
        public bool LocalPromotion_DeleteByIDItemAndIDRestaurant(int iditem, int idrestaurant)
        {
            var rpt = new LocalPromotionRepository();
            return rpt.DeleteByIDItemAndIDRestaurant(iditem, idrestaurant);
        }
		public bool LocalPromotion_Update(LocalPromotionDTO obj)
		{
			var rpt = new LocalPromotionRepository();
			var entity = rpt.SelectByID(obj.ID);
			obj.UpdateEntity(ref entity);
			return rpt.Save();
		}
		public List<LocalPromotionDTO> LocalPromotion_RetrieveByID(int id)
		{
			var rpt = new LocalPromotionRepository();
			var lstDto = new List<LocalPromotionDTO>();
			var lstEntity = rpt.RetrieveByID(id);
			foreach (var item in lstEntity)
			{
				lstDto.Add(LocalPromotionDTO.Translate(item));
			}
			return lstDto;
		}
		public List<LocalPromotionDTO> LocalPromotion_SelectByIDItem(int iditem)
		{
			var rpt = new LocalPromotionRepository();
			var lstDto = new List<LocalPromotionDTO>();
			var lstEntity = rpt.SelectByIDItem(iditem);
			foreach (var item in lstEntity)
			{
				lstDto.Add(LocalPromotionDTO.Translate(item));
			}
			return lstDto;
		}
		public List<LocalPromotionDTO> LocalPromotion_SelectByIDRestaurant(int idrestaurant)
		{
			var rpt = new LocalPromotionRepository();
			var lstDto = new List<LocalPromotionDTO>();
			var lstEntity = rpt.SelectByIDRestaurant(idrestaurant);
			foreach (var item in lstEntity)
			{
				lstDto.Add(LocalPromotionDTO.Translate(item));
			}
			return lstDto;
		}
        public LocalPromotionDTO LocalPromotion_SelectByIDItemAndIDRestaurant(int iditem, int idrestaurant)
        {
            var rpt = new LocalPromotionRepository();
            return LocalPromotionDTO.Translate(rpt.SelectByIDItemAndIDRestaurant(iditem, idrestaurant));
        }
		/////////////////// ORDERS ///////////////////
		public List<OrdersDTO> Orders_SelectAll()
		{
			var lstDto = new List<OrdersDTO>();
			var rpt = new OrdersRepository();
			var lstEntity = rpt.SelectAll();
			foreach (var item in lstEntity)
			{
				lstDto.Add(OrdersDTO.Translate(item));
			}
			return lstDto;
		}
		public OrdersDTO Orders_SelectByID(int id)
		{
			var rpt = new OrdersRepository();
			return OrdersDTO.Translate(rpt.SelectByID(id));
		}
		public bool Orders_Insert(ref OrdersDTO obj)
		{
			var rpt = new OrdersRepository();
			var entity = OrdersDTO.Reverse(obj);
			var result = rpt.Insert(entity);
            if (result)
            {
                obj.ID = entity.ID;
            }
            return result;
		}
		public bool Orders_Delete(int id)
		{
			var rpt = new OrdersRepository();
			return rpt.Delete(id);
		}
		public bool Orders_Update(OrdersDTO obj)
		{
			var rpt = new OrdersRepository();
			var entity = rpt.SelectByID(obj.ID);
			obj.UpdateEntity(ref entity);
			return rpt.Save();
		}
		public List<OrdersDTO> Orders_RetrieveByID(int id)
		{
			var rpt = new OrdersRepository();
			var lstDto = new List<OrdersDTO>();
			var lstEntity = rpt.RetrieveByID(id);
			foreach (var item in lstEntity)
			{
				lstDto.Add(OrdersDTO.Translate(item));
			}
			return lstDto;
		}
		public List<OrdersDTO> Orders_SelectByIDRestaurant(int idrestaurant)
		{
            try
            {
                var rpt = new OrdersRepository();
                var lstDto = new List<OrdersDTO>();
                var lstEntity = rpt.SelectByIDRestaurant(idrestaurant);
                foreach (var item in lstEntity)
                {
                    lstDto.Add(OrdersDTO.Translate(item));
                }
                return lstDto;
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    GlobalVariables.Logger.Error(ex.InnerException.Message);
                }
                else
                {
                    GlobalVariables.Logger.Error(ex.Message);
                }
            }
            return new List<OrdersDTO>();
		}
        public List<OrdersDTO> Orders_SelectByIDRestaurantAndOrderDate(int idrestaurant, DateTime orderdate)
        {
            try
            {
                var rpt = new OrdersRepository();
                var lstDto = new List<OrdersDTO>();
                var lstEntity = rpt.SelectByIDRestaurantAndOrderDate(idrestaurant, orderdate);
                foreach (var item in lstEntity)
                {
                    lstDto.Add(OrdersDTO.Translate(item));
                }
                return lstDto;
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    GlobalVariables.Logger.Error(ex.InnerException.Message);
                }
                else
                {
                    GlobalVariables.Logger.Error(ex.Message);
                }
            }
            return new List<OrdersDTO>();
        }
		/////////////////// ORDERDETAIL ///////////////////
		public List<OrderDetailDTO> OrderDetail_SelectAll()
		{
			var lstDto = new List<OrderDetailDTO>();
			var rpt = new OrderDetailRepository();
			var lstEntity = rpt.SelectAll();
			foreach (var item in lstEntity)
			{
				lstDto.Add(OrderDetailDTO.Translate(item));
			}
			return lstDto;
		}
		public OrderDetailDTO OrderDetail_SelectByID(int id)
		{
			var rpt = new OrderDetailRepository();
			return OrderDetailDTO.Translate(rpt.SelectByID(id));
		}
		public bool OrderDetail_Insert(OrderDetailDTO obj)
		{
			var rpt = new OrderDetailRepository();
			var entity = OrderDetailDTO.Reverse(obj);
			return rpt.Insert(entity);
		}
		public bool OrderDetail_Delete(int id)
		{
			var rpt = new OrderDetailRepository();
			return rpt.Delete(id);
		}
        public bool OrderDetail_DeleteByOrder(int idorder)
        {
            var rpt = new OrderDetailRepository();
            return rpt.DeleteByOrder(idorder);
        }
		public bool OrderDetail_Update(OrderDetailDTO obj)
		{
			var rpt = new OrderDetailRepository();
			var entity = rpt.SelectByID(obj.ID);
			obj.UpdateEntity(ref entity);
			return rpt.Save();
		}
		public List<OrderDetailDTO> OrderDetail_RetrieveByID(int id)
		{
			var rpt = new OrderDetailRepository();
			var lstDto = new List<OrderDetailDTO>();
			var lstEntity = rpt.RetrieveByID(id);
			foreach (var item in lstEntity)
			{
				lstDto.Add(OrderDetailDTO.Translate(item));
			}
			return lstDto;
		}
		public List<OrderDetailDTO> OrderDetail_SelectByIDOrder(int idorder)
		{
			var rpt = new OrderDetailRepository();
			var lstDto = new List<OrderDetailDTO>();
			var lstEntity = rpt.SelectByIDOrder(idorder);
			foreach (var item in lstEntity)
			{
				lstDto.Add(OrderDetailDTO.Translate(item));
			}
			return lstDto;
		}
		public List<OrderDetailDTO> OrderDetail_SelectByIDItem(int iditem)
		{
			var rpt = new OrderDetailRepository();
			var lstDto = new List<OrderDetailDTO>();
			var lstEntity = rpt.SelectByIDItem(iditem);
			foreach (var item in lstEntity)
			{
				lstDto.Add(OrderDetailDTO.Translate(item));
			}
			return lstDto;
		}
		/////////////////// ROLEFUNCTIONS ///////////////////
		public List<RoleFunctionsDTO> RoleFunctions_SelectAll()
		{
			var lstDto = new List<RoleFunctionsDTO>();
			var rpt = new RoleFunctionsRepository();
			var lstEntity = rpt.SelectAll();
			foreach (var item in lstEntity)
			{
				lstDto.Add(RoleFunctionsDTO.Translate(item));
			}
			return lstDto;
		}
		public RoleFunctionsDTO RoleFunctions_SelectByID(int id)
		{
			var rpt = new RoleFunctionsRepository();
			return RoleFunctionsDTO.Translate(rpt.SelectByID(id));
		}
		public bool RoleFunctions_Insert(RoleFunctionsDTO obj)
		{
			var rpt = new RoleFunctionsRepository();
			var entity = RoleFunctionsDTO.Reverse(obj);
			return rpt.Insert(entity);
		}
		public bool RoleFunctions_Delete(int id)
		{
			var rpt = new RoleFunctionsRepository();
			return rpt.Delete(id);
		}
		public bool RoleFunctions_Update(RoleFunctionsDTO obj)
		{
			var rpt = new RoleFunctionsRepository();
			var entity = rpt.SelectByID(obj.ID);
			obj.UpdateEntity(ref entity);
			return rpt.Save();
		}
		public List<RoleFunctionsDTO> RoleFunctions_RetrieveByID(int id)
		{
			var rpt = new RoleFunctionsRepository();
			var lstDto = new List<RoleFunctionsDTO>();
			var lstEntity = rpt.RetrieveByID(id);
			foreach (var item in lstEntity)
			{
				lstDto.Add(RoleFunctionsDTO.Translate(item));
			}
			return lstDto;
		}
		public List<RoleFunctionsDTO> RoleFunctions_SelectByIDRole(int idrole)
		{
			var rpt = new RoleFunctionsRepository();
			var lstDto = new List<RoleFunctionsDTO>();
			var lstEntity = rpt.SelectByIDRole(idrole);
			foreach (var item in lstEntity)
			{
				lstDto.Add(RoleFunctionsDTO.Translate(item));
			}
			return lstDto;
		}
		public List<RoleFunctionsDTO> RoleFunctions_SelectByIDFunction(int idfunction)
		{
			var rpt = new RoleFunctionsRepository();
			var lstDto = new List<RoleFunctionsDTO>();
			var lstEntity = rpt.SelectByIDFunction(idfunction);
			foreach (var item in lstEntity)
			{
				lstDto.Add(RoleFunctionsDTO.Translate(item));
			}
			return lstDto;
		}
		/////////////////// FUNCTIONS ///////////////////
		public List<FunctionsDTO> Functions_SelectAll()
		{
			var lstDto = new List<FunctionsDTO>();
			var rpt = new FunctionsRepository();
			var lstEntity = rpt.SelectAll();
			foreach (var item in lstEntity)
			{
				lstDto.Add(FunctionsDTO.Translate(item));
			}
			return lstDto;
		}
		public FunctionsDTO Functions_SelectByID(int id)
		{
			var rpt = new FunctionsRepository();
			return FunctionsDTO.Translate(rpt.SelectByID(id));
		}
		public bool Functions_Insert(FunctionsDTO obj)
		{
			var rpt = new FunctionsRepository();
			var entity = FunctionsDTO.Reverse(obj);
			return rpt.Insert(entity);
		}
		public bool Functions_Delete(int id)
		{
			var rpt = new FunctionsRepository();
			return rpt.Delete(id);
		}
		public bool Functions_Update(FunctionsDTO obj)
		{
			var rpt = new FunctionsRepository();
			var entity = rpt.SelectByID(obj.ID);
			obj.UpdateEntity(ref entity);
			return rpt.Save();
		}
		public List<FunctionsDTO> Functions_RetrieveByID(int id)
		{
			var rpt = new FunctionsRepository();
			var lstDto = new List<FunctionsDTO>();
			var lstEntity = rpt.RetrieveByID(id);
			foreach (var item in lstEntity)
			{
				lstDto.Add(FunctionsDTO.Translate(item));
			}
			return lstDto;
		}
		/////////////////// ROLE ///////////////////
		public List<RoleDTO> Role_SelectAll()
		{
			var lstDto = new List<RoleDTO>();
			var rpt = new RoleRepository();
			var lstEntity = rpt.SelectAll();
			foreach (var item in lstEntity)
			{
				lstDto.Add(RoleDTO.Translate(item));
			}
			return lstDto;
		}
		public RoleDTO Role_SelectByID(int id)
		{
			var rpt = new RoleRepository();
			return RoleDTO.Translate(rpt.SelectByID(id));
		}
		public bool Role_Insert(RoleDTO obj)
		{
			var rpt = new RoleRepository();
			var entity = RoleDTO.Reverse(obj);
			return rpt.Insert(entity);
		}
		public bool Role_Delete(int id)
		{
			var rpt = new RoleRepository();
			return rpt.Delete(id);
		}
		public bool Role_Update(RoleDTO obj)
		{
			var rpt = new RoleRepository();
			var entity = rpt.SelectByID(obj.ID);
			obj.UpdateEntity(ref entity);
			return rpt.Save();
		}
		public List<RoleDTO> Role_RetrieveByID(int id)
		{
			var rpt = new RoleRepository();
			var lstDto = new List<RoleDTO>();
			var lstEntity = rpt.RetrieveByID(id);
			foreach (var item in lstEntity)
			{
				lstDto.Add(RoleDTO.Translate(item));
			}
			return lstDto;
		}
		/////////////////// RESTAURANT ///////////////////
		public List<RestaurantDTO> Restaurant_SelectAll()
		{
			var lstDto = new List<RestaurantDTO>();
			var rpt = new RestaurantRepository();
			var lstEntity = rpt.SelectAll();
			foreach (var item in lstEntity)
			{
				lstDto.Add(RestaurantDTO.Translate(item));
			}
			return lstDto;
		}
		public RestaurantDTO Restaurant_SelectByID(int id)
		{
			var rpt = new RestaurantRepository();
			return RestaurantDTO.Translate(rpt.SelectByID(id));
		}
		public bool Restaurant_Insert(RestaurantDTO obj)
		{
			var rpt = new RestaurantRepository();
			var entity = RestaurantDTO.Reverse(obj);
			return rpt.Insert(entity);
		}
		public bool Restaurant_Delete(int id)
		{
			var rpt = new RestaurantRepository();
			return rpt.Delete(id);
		}
		public bool Restaurant_Update(RestaurantDTO obj)
		{
			var rpt = new RestaurantRepository();
			var entity = rpt.SelectByID(obj.ID);
			obj.UpdateEntity(ref entity);
			return rpt.Save();
		}
		public List<RestaurantDTO> Restaurant_RetrieveByID(int id)
		{
			var rpt = new RestaurantRepository();
			var lstDto = new List<RestaurantDTO>();
			var lstEntity = rpt.RetrieveByID(id);
			foreach (var item in lstEntity)
			{
				lstDto.Add(RestaurantDTO.Translate(item));
			}
			return lstDto;
		}
	}
}
